package com.test.controller;

import com.test.domain.User;
import com.test.enums.Replay;
import com.test.service.LoginService;
import com.test.service.UserService;
import com.test.utils.SendURL;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Login
 *
 * @author HY
 * 2021/05/13 9:41
 **/

@Api(tags = "微信用户登陆api")
@RestController
@RequestMapping("/wx/Login")
public class WX_LoginController {

    @Resource
    private LoginService loginService;

    @GetMapping("/getOppenid")
    @ApiOperation("查询是否存在用户，并返回用户id")
    public Replay getoppenid(@RequestParam String js_code){

        Replay replay = loginService.isOppenid(js_code);

        return replay;
    }

    @PostMapping(value = "/addUser")
    @ApiOperation("添加用户信息")
    public Replay addUser(@RequestBody User user){
        System.out.println(user);
        Replay replay = loginService.addUser(user);

        return replay;
    }

}
